public final class Renderer3D extends Renderer2D {
	public static void nullLoader() {
		Renderer3D.gradientFactors = null;
		Renderer3D.gradientFactors = null;
		Renderer3D.sineTable = null;
		Renderer3D.cosineTable = null;
		Renderer3D.lineOffsets = null;
		Renderer3D.textures = null;
		Renderer3D.alphaTextures = null;
		Renderer3D.averageTextureColors = null;
		Renderer3D.texturePool = null;
		Renderer3D.textureCache = null;
		Renderer3D.texturePriorities = null;
		Renderer3D.invertedPalette = null;
		Renderer3D.texturePixels = null;
	}

	public static void method364() {
		Renderer3D.lineOffsets = new int[Renderer2D.height];
		for (int j = 0; j < Renderer2D.height; j++) {
			Renderer3D.lineOffsets[j] = Renderer2D.width * j;
		}
		Renderer3D.middleX = Renderer2D.width / 2;
		Renderer3D.middleY = Renderer2D.height / 2;
	}

	public static void init(int x, int y) {
		Renderer3D.lineOffsets = new int[y];
		for (int l = 0; l < y; l++) {
			Renderer3D.lineOffsets[l] = x * l;
		}
		Renderer3D.middleX = x / 2;
		Renderer3D.middleY = y / 2;
	}

	public static void clearTextures() {
		Renderer3D.texturePool = null;
		for (int j = 0; j < 50; j++) {
			Renderer3D.textureCache[j] = null;
		}
	}

	public static void resetTextures() {
		if (Renderer3D.texturePool == null) {
			Renderer3D.loadedTextures = 20;
			if (Renderer3D.lowMem) {
				Renderer3D.texturePool = new int[Renderer3D.loadedTextures][16384];
			} else {
				Renderer3D.texturePool = new int[Renderer3D.loadedTextures][0x10000];
			}
			for (int k = 0; k < 50; k++) {
				Renderer3D.textureCache[k] = null;
			}
		}
	}

	public static void unpackTextures(Archive achive) {
		Renderer3D.textureCount = 0;
		for (int j = 0; j < 50; j++) {
			try {
				Renderer3D.textures[j] = new IndexedSprite(achive, String.valueOf(j), 0);
				if (Renderer3D.lowMem && (Renderer3D.textures[j].trimWidth == 128)) {
					Renderer3D.textures[j].shrink();
				} else {
					Renderer3D.textures[j].trim();
				}
				Renderer3D.textureCount++;
			} catch (Exception _ex) {
			}
		}
	}

	public static int getAverageColor(int i) {
		if (Renderer3D.averageTextureColors[i] != 0) {
			return Renderer3D.averageTextureColors[i];
		}
		int red = 0;
		int green = 0;
		int blue = 0;
		int colorCount = Renderer3D.texturePixels[i].length;
		for (int k1 = 0; k1 < colorCount; k1++) {
			red += Renderer3D.texturePixels[i][k1] >> 16 & 0xff;
			green += Renderer3D.texturePixels[i][k1] >> 8 & 0xff;
			blue += Renderer3D.texturePixels[i][k1] & 0xff;
		}
		int average = (red / colorCount << 16) + (green / colorCount << 8) + blue / colorCount;
		average = Renderer3D.adjustBrightness(average, 1.3999999999999999D);
		if (average == 0) {
			average = 1;
		}
		Renderer3D.averageTextureColors[i] = average;
		return average;
	}

	public static void loadTexture(int texture) {
		if (Renderer3D.textureCache[texture] == null) {
			return;
		}
		Renderer3D.texturePool[Renderer3D.loadedTextures++] = Renderer3D.textureCache[texture];
		Renderer3D.textureCache[texture] = null;
	}

	private static int[] getTexture(int texture) {
		Renderer3D.texturePriorities[texture] = Renderer3D.priority++;
		if (Renderer3D.textureCache[texture] != null) {
			return Renderer3D.textureCache[texture];
		}
		int textureData[];
		if (Renderer3D.loadedTextures > 0) {
			textureData = Renderer3D.texturePool[--Renderer3D.loadedTextures];
			Renderer3D.texturePool[Renderer3D.loadedTextures] = null;
		} else {
			int lowest = 0;
			int textureCacheId = -1;
			for (int i = 0; i < Renderer3D.textureCount; i++) {
				if ((Renderer3D.textureCache[i] != null)
				&& ((Renderer3D.texturePriorities[i] < lowest) || (textureCacheId == -1))) {
					lowest = Renderer3D.texturePriorities[i];
					textureCacheId = i;
				}
			}
			textureData = Renderer3D.textureCache[textureCacheId];
			Renderer3D.textureCache[textureCacheId] = null;
		}
		Renderer3D.textureCache[texture] = textureData;
		IndexedSprite indexedSprite = Renderer3D.textures[texture];
		int pixels[] = Renderer3D.texturePixels[texture];
		if (Renderer3D.lowMem) {
			Renderer3D.alphaTextures[texture] = false;
			for (int i = 0; i < 4096; i++) {
				int i2 = textureData[i] = pixels[indexedSprite.pixels[i]] & 0xf8f8ff;
				if (i2 == 0) {
					Renderer3D.alphaTextures[texture] = true;
				}
				textureData[4096 + i] = i2 - (i2 >>> 3) & 0xf8f8ff;
				textureData[8192 + i] = i2 - (i2 >>> 2) & 0xf8f8ff;
				textureData[12288 + i] = i2 - (i2 >>> 2) - (i2 >>> 3) & 0xf8f8ff;
			}
		} else {
			if (indexedSprite.width == 64) {
				for (int i3 = 0; i3 < 128; i3++) {
					for (int i4 = 0; i4 < 128; i4++) {
						textureData[i4 + (i3 << 7)] = pixels[indexedSprite.pixels[(i4 >> 1)
						+ ((i3 >> 1) << 6)]];
					}
				}
			} else {
				for (int i5 = 0; i5 < 16384; i5++) {
					textureData[i5] = pixels[indexedSprite.pixels[i5]];
				}
			}
			Renderer3D.alphaTextures[texture] = false;
			for (int i6 = 0; i6 < 16384; i6++) {
				textureData[i6] &= 0xf8f8ff;
				int i7 = textureData[i6];
				if (i7 == 0) {
					Renderer3D.alphaTextures[texture] = true;
				}
				textureData[16384 + i6] = i7 - (i7 >>> 3) & 0xf8f8ff;
				textureData[32768 + i6] = i7 - (i7 >>> 2) & 0xf8f8ff;
				textureData[49152 + i6] = i7 - (i7 >>> 2) - (i7 >>> 3) & 0xf8f8ff;
			}
		}
		return textureData;
	}

	public static void setPallete(double d) {
		d += Math.random() * 0.029999999999999999D - 0.014999999999999999D;
		int j = 0;
		for (int k = 0; k < 512; k++) {
			double d1 = (k / 8) / 64D + 0.0078125D;
			double d2 = (k & 7) / 8D + 0.0625D;
			for (int k1 = 0; k1 < 128; k1++) {
				double d3 = k1 / 128D;
				double destRed = d3;
				double destGreen = d3;
				double destBlue = d3;
				if (d2 != 0.0D) {
					double d7;
					if (d3 < 0.5D) {
						d7 = d3 * (1.0D + d2);
					} else {
						d7 = (d3 + d2) - d3 * d2;
					}
					double d8 = 2D * d3 - d7;
					double d9 = d1 + 0.33333333333333331D;
					if (d9 > 1.0D) {
						d9--;
					}
					double d10 = d1;
					double d11 = d1 - 0.33333333333333331D;
					if (d11 < 0.0D) {
						d11++;
					}
					if (6D * d9 < 1.0D) {
						destRed = d8 + (d7 - d8) * 6D * d9;
					} else if (2D * d9 < 1.0D) {
						destRed = d7;
					} else if (3D * d9 < 2D) {
						destRed = d8 + (d7 - d8) * (0.66666666666666663D - d9) * 6D;
					} else {
						destRed = d8;
					}
					if (6D * d10 < 1.0D) {
						destGreen = d8 + (d7 - d8) * 6D * d10;
					} else if (2D * d10 < 1.0D) {
						destGreen = d7;
					} else if (3D * d10 < 2D) {
						destGreen = d8 + (d7 - d8) * (0.66666666666666663D - d10) * 6D;
					} else {
						destGreen = d8;
					}
					if (6D * d11 < 1.0D) {
						destBlue = d8 + (d7 - d8) * 6D * d11;
					} else if (2D * d11 < 1.0D) {
						destBlue = d7;
					} else if (3D * d11 < 2D) {
						destBlue = d8 + (d7 - d8) * (0.66666666666666663D - d11) * 6D;
					} else {
						destBlue = d8;
					}
				}
				int red = (int) (destRed * 256D);
				int green = (int) (destGreen * 256D);
				int blue = (int) (destBlue * 256D);
				int rgb = (red << 16) + (green << 8) + blue;
				rgb = Renderer3D.adjustBrightness(rgb, d);
				if (rgb == 0) {
					rgb = 1;
				}
				Renderer3D.invertedPalette[j++] = rgb;
			}
		}
		for (int i = 0; i < 50; i++) {
			if (Renderer3D.textures[i] != null) {
				int newPixels[] = Renderer3D.textures[i].pallete;
				Renderer3D.texturePixels[i] = new int[newPixels.length];
				for (int j1 = 0; j1 < newPixels.length; j1++) {
					Renderer3D.texturePixels[i][j1] = Renderer3D.adjustBrightness(newPixels[j1], d);
					if (((Renderer3D.texturePixels[i][j1] & 0xf8f8ff) == 0) && (j1 != 0)) {
						Renderer3D.texturePixels[i][j1] = 1;
					}
				}
			}
		}
		for (int i2 = 0; i2 < 50; i2++) {
			Renderer3D.loadTexture(i2);
		}
	}

	private static int adjustBrightness(int rgb, double d) {
		double destRed = (rgb >> 16) / 256D;
		double destGreen = (rgb >> 8 & 0xff) / 256D;
		double destBlue = (rgb & 0xff) / 256D;
		destRed = Math.pow(destRed, d);
		destGreen = Math.pow(destGreen, d);
		destBlue = Math.pow(destBlue, d);
		int red = (int) (destRed * 256D);
		int green = (int) (destGreen * 256D);
		int blue = (int) (destBlue * 256D);
		return (red << 16) + (green << 8) + blue;
	}

	public static void drawShadedTriangle(int y1, int y2, int y3, int x1, int x2, int x3,
	int gradian1, int gradian2, int gradian3) {
		int slope1 = 0;
		int slope2 = 0;
		if (y2 != y1) {
			slope1 = (x2 - x1 << 16) / (y2 - y1);
			slope2 = (gradian2 - gradian1 << 15) / (y2 - y1);
		}
		int slope3 = 0;
		int slope4 = 0;
		if (y3 != y2) {
			slope3 = (x3 - x2 << 16) / (y3 - y2);
			slope4 = (gradian3 - gradian2 << 15) / (y3 - y2);
		}
		int slope5 = 0;
		int slope6 = 0;
		if (y3 != y1) {
			slope5 = (x1 - x3 << 16) / (y1 - y3);
			slope6 = (gradian1 - gradian3 << 15) / (y1 - y3);
		}
		if ((y1 <= y2) && (y1 <= y3)) {
			if (y1 >= Renderer2D.bottomY) {
				return;
			}
			if (y2 > Renderer2D.bottomY) {
				y2 = Renderer2D.bottomY;
			}
			if (y3 > Renderer2D.bottomY) {
				y3 = Renderer2D.bottomY;
			}
			if (y2 < y3) {
				x3 = x1 <<= 16;
				gradian3 = gradian1 <<= 15;
				if (y1 < 0) {
					x3 -= slope5 * y1;
					x1 -= slope1 * y1;
					gradian3 -= slope6 * y1;
					gradian1 -= slope2 * y1;
					y1 = 0;
				}
				x2 <<= 16;
				gradian2 <<= 15;
				if (y2 < 0) {
					x2 -= slope3 * y2;
					gradian2 -= slope4 * y2;
					y2 = 0;
				}
				if (((y1 != y2) && (slope5 < slope1)) || ((y1 == y2) && (slope5 > slope3))) {
					y3 -= y2;
					y2 -= y1;
					for (y1 = Renderer3D.lineOffsets[y1]; --y2 >= 0; y1 += Renderer2D.width) {
						Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x3 >> 16, x1 >> 16,
						gradian3 >> 7, gradian1 >> 7);
						x3 += slope5;
						x1 += slope1;
						gradian3 += slope6;
						gradian1 += slope2;
					}
					while (--y3 >= 0) {
						Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x3 >> 16, x2 >> 16,
						gradian3 >> 7, gradian2 >> 7);
						x3 += slope5;
						x2 += slope3;
						gradian3 += slope6;
						gradian2 += slope4;
						y1 += Renderer2D.width;
					}
					return;
				}
				y3 -= y2;
				y2 -= y1;
				for (y1 = Renderer3D.lineOffsets[y1]; --y2 >= 0; y1 += Renderer2D.width) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x1 >> 16, x3 >> 16,
					gradian1 >> 7, gradian3 >> 7);
					x3 += slope5;
					x1 += slope1;
					gradian3 += slope6;
					gradian1 += slope2;
				}
				while (--y3 >= 0) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x2 >> 16, x3 >> 16,
					gradian2 >> 7, gradian3 >> 7);
					x3 += slope5;
					x2 += slope3;
					gradian3 += slope6;
					gradian2 += slope4;
					y1 += Renderer2D.width;
				}
				return;
			}
			x2 = x1 <<= 16;
			gradian2 = gradian1 <<= 15;
			if (y1 < 0) {
				x2 -= slope5 * y1;
				x1 -= slope1 * y1;
				gradian2 -= slope6 * y1;
				gradian1 -= slope2 * y1;
				y1 = 0;
			}
			x3 <<= 16;
			gradian3 <<= 15;
			if (y3 < 0) {
				x3 -= slope3 * y3;
				gradian3 -= slope4 * y3;
				y3 = 0;
			}
			if (((y1 != y3) && (slope5 < slope1)) || ((y1 == y3) && (slope3 > slope1))) {
				y2 -= y3;
				y3 -= y1;
				for (y1 = Renderer3D.lineOffsets[y1]; --y3 >= 0; y1 += Renderer2D.width) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x2 >> 16, x1 >> 16,
					gradian2 >> 7, gradian1 >> 7);
					x2 += slope5;
					x1 += slope1;
					gradian2 += slope6;
					gradian1 += slope2;
				}
				while (--y2 >= 0) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x3 >> 16, x1 >> 16,
					gradian3 >> 7, gradian1 >> 7);
					x3 += slope3;
					x1 += slope1;
					gradian3 += slope4;
					gradian1 += slope2;
					y1 += Renderer2D.width;
				}
				return;
			}
			y2 -= y3;
			y3 -= y1;
			for (y1 = Renderer3D.lineOffsets[y1]; --y3 >= 0; y1 += Renderer2D.width) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x1 >> 16, x2 >> 16, gradian1 >> 7,
				gradian2 >> 7);
				x2 += slope5;
				x1 += slope1;
				gradian2 += slope6;
				gradian1 += slope2;
			}
			while (--y2 >= 0) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y1, x1 >> 16, x3 >> 16, gradian1 >> 7,
				gradian3 >> 7);
				x3 += slope3;
				x1 += slope1;
				gradian3 += slope4;
				gradian1 += slope2;
				y1 += Renderer2D.width;
			}
			return;
		}
		if (y2 <= y3) {
			if (y2 >= Renderer2D.bottomY) {
				return;
			}
			if (y3 > Renderer2D.bottomY) {
				y3 = Renderer2D.bottomY;
			}
			if (y1 > Renderer2D.bottomY) {
				y1 = Renderer2D.bottomY;
			}
			if (y3 < y1) {
				x1 = x2 <<= 16;
				gradian1 = gradian2 <<= 15;
				if (y2 < 0) {
					x1 -= slope1 * y2;
					x2 -= slope3 * y2;
					gradian1 -= slope2 * y2;
					gradian2 -= slope4 * y2;
					y2 = 0;
				}
				x3 <<= 16;
				gradian3 <<= 15;
				if (y3 < 0) {
					x3 -= slope5 * y3;
					gradian3 -= slope6 * y3;
					y3 = 0;
				}
				if (((y2 != y3) && (slope1 < slope3)) || ((y2 == y3) && (slope1 > slope5))) {
					y1 -= y3;
					y3 -= y2;
					for (y2 = Renderer3D.lineOffsets[y2]; --y3 >= 0; y2 += Renderer2D.width) {
						Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x1 >> 16, x2 >> 16,
						gradian1 >> 7, gradian2 >> 7);
						x1 += slope1;
						x2 += slope3;
						gradian1 += slope2;
						gradian2 += slope4;
					}
					while (--y1 >= 0) {
						Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x1 >> 16, x3 >> 16,
						gradian1 >> 7, gradian3 >> 7);
						x1 += slope1;
						x3 += slope5;
						gradian1 += slope2;
						gradian3 += slope6;
						y2 += Renderer2D.width;
					}
					return;
				}
				y1 -= y3;
				y3 -= y2;
				for (y2 = Renderer3D.lineOffsets[y2]; --y3 >= 0; y2 += Renderer2D.width) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x2 >> 16, x1 >> 16,
					gradian2 >> 7, gradian1 >> 7);
					x1 += slope1;
					x2 += slope3;
					gradian1 += slope2;
					gradian2 += slope4;
				}
				while (--y1 >= 0) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x3 >> 16, x1 >> 16,
					gradian3 >> 7, gradian1 >> 7);
					x1 += slope1;
					x3 += slope5;
					gradian1 += slope2;
					gradian3 += slope6;
					y2 += Renderer2D.width;
				}
				return;
			}
			x3 = x2 <<= 16;
			gradian3 = gradian2 <<= 15;
			if (y2 < 0) {
				x3 -= slope1 * y2;
				x2 -= slope3 * y2;
				gradian3 -= slope2 * y2;
				gradian2 -= slope4 * y2;
				y2 = 0;
			}
			x1 <<= 16;
			gradian1 <<= 15;
			if (y1 < 0) {
				x1 -= slope5 * y1;
				gradian1 -= slope6 * y1;
				y1 = 0;
			}
			if (slope1 < slope3) {
				y3 -= y1;
				y1 -= y2;
				for (y2 = Renderer3D.lineOffsets[y2]; --y1 >= 0; y2 += Renderer2D.width) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x3 >> 16, x2 >> 16,
					gradian3 >> 7, gradian2 >> 7);
					x3 += slope1;
					x2 += slope3;
					gradian3 += slope2;
					gradian2 += slope4;
				}
				while (--y3 >= 0) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x1 >> 16, x2 >> 16,
					gradian1 >> 7, gradian2 >> 7);
					x1 += slope5;
					x2 += slope3;
					gradian1 += slope6;
					gradian2 += slope4;
					y2 += Renderer2D.width;
				}
				return;
			}
			y3 -= y1;
			y1 -= y2;
			for (y2 = Renderer3D.lineOffsets[y2]; --y1 >= 0; y2 += Renderer2D.width) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x2 >> 16, x3 >> 16, gradian2 >> 7,
				gradian3 >> 7);
				x3 += slope1;
				x2 += slope3;
				gradian3 += slope2;
				gradian2 += slope4;
			}
			while (--y3 >= 0) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y2, x2 >> 16, x1 >> 16, gradian2 >> 7,
				gradian1 >> 7);
				x1 += slope5;
				x2 += slope3;
				gradian1 += slope6;
				gradian2 += slope4;
				y2 += Renderer2D.width;
			}
			return;
		}
		if (y3 >= Renderer2D.bottomY) {
			return;
		}
		if (y1 > Renderer2D.bottomY) {
			y1 = Renderer2D.bottomY;
		}
		if (y2 > Renderer2D.bottomY) {
			y2 = Renderer2D.bottomY;
		}
		if (y1 < y2) {
			x2 = x3 <<= 16;
			gradian2 = gradian3 <<= 15;
			if (y3 < 0) {
				x2 -= slope3 * y3;
				x3 -= slope5 * y3;
				gradian2 -= slope4 * y3;
				gradian3 -= slope6 * y3;
				y3 = 0;
			}
			x1 <<= 16;
			gradian1 <<= 15;
			if (y1 < 0) {
				x1 -= slope1 * y1;
				gradian1 -= slope2 * y1;
				y1 = 0;
			}
			if (slope3 < slope5) {
				y2 -= y1;
				y1 -= y3;
				for (y3 = Renderer3D.lineOffsets[y3]; --y1 >= 0; y3 += Renderer2D.width) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x2 >> 16, x3 >> 16,
					gradian2 >> 7, gradian3 >> 7);
					x2 += slope3;
					x3 += slope5;
					gradian2 += slope4;
					gradian3 += slope6;
				}
				while (--y2 >= 0) {
					Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x2 >> 16, x1 >> 16,
					gradian2 >> 7, gradian1 >> 7);
					x2 += slope3;
					x1 += slope1;
					gradian2 += slope4;
					gradian1 += slope2;
					y3 += Renderer2D.width;
				}
				return;
			}
			y2 -= y1;
			y1 -= y3;
			for (y3 = Renderer3D.lineOffsets[y3]; --y1 >= 0; y3 += Renderer2D.width) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x3 >> 16, x2 >> 16, gradian3 >> 7,
				gradian2 >> 7);
				x2 += slope3;
				x3 += slope5;
				gradian2 += slope4;
				gradian3 += slope6;
			}
			while (--y2 >= 0) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x1 >> 16, x2 >> 16, gradian1 >> 7,
				gradian2 >> 7);
				x2 += slope3;
				x1 += slope1;
				gradian2 += slope4;
				gradian1 += slope2;
				y3 += Renderer2D.width;
			}
			return;
		}
		x1 = x3 <<= 16;
		gradian1 = gradian3 <<= 15;
		if (y3 < 0) {
			x1 -= slope3 * y3;
			x3 -= slope5 * y3;
			gradian1 -= slope4 * y3;
			gradian3 -= slope6 * y3;
			y3 = 0;
		}
		x2 <<= 16;
		gradian2 <<= 15;
		if (y2 < 0) {
			x2 -= slope1 * y2;
			gradian2 -= slope2 * y2;
			y2 = 0;
		}
		if (slope3 < slope5) {
			y1 -= y2;
			y2 -= y3;
			for (y3 = Renderer3D.lineOffsets[y3]; --y2 >= 0; y3 += Renderer2D.width) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x1 >> 16, x3 >> 16, gradian1 >> 7,
				gradian3 >> 7);
				x1 += slope3;
				x3 += slope5;
				gradian1 += slope4;
				gradian3 += slope6;
			}
			while (--y1 >= 0) {
				Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x2 >> 16, x3 >> 16, gradian2 >> 7,
				gradian3 >> 7);
				x2 += slope1;
				x3 += slope5;
				gradian2 += slope2;
				gradian3 += slope6;
				y3 += Renderer2D.width;
			}
			return;
		}
		y1 -= y2;
		y2 -= y3;
		for (y3 = Renderer3D.lineOffsets[y3]; --y2 >= 0; y3 += Renderer2D.width) {
			Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x3 >> 16, x1 >> 16, gradian3 >> 7,
			gradian1 >> 7);
			x1 += slope3;
			x3 += slope5;
			gradian1 += slope4;
			gradian3 += slope6;
		}
		while (--y1 >= 0) {
			Renderer3D.drawShadedLine(Renderer2D.pixels, y3, x3 >> 16, x2 >> 16, gradian3 >> 7,
			gradian2 >> 7);
			x2 += slope1;
			x3 += slope5;
			gradian2 += slope2;
			gradian3 += slope6;
			y3 += Renderer2D.width;
		}
	}

	public static void drawShadedLine(int[] pixels, int offset, int startX, int endX,
	int colorIndex, int gradient) {
		int rgb;
		int color;
		int src = 0;
		if (edgeRestricted) {//aBoolean1462
			if (endX > Renderer2D.endX)
				endX = Renderer2D.endX;
			if (startX < 0) {
				colorIndex -= startX * src;
				startX = 0;
			}
		}
		if (startX < endX) {
			offset += startX;
			colorIndex += src * startX;
			if (colorRestricted) {//aBoolean1464
				color = endX - startX >> 2;
				if (color > 0) {
					src = (gradient - colorIndex) * gradientFactors[color] >> 15;//anIntArray1468
				} else {
					src = 0;
				}
				if (alpha == 0) {//anInt1465
					if (color > 0) {
						do {
							rgb = invertedPalette[colorIndex >> 8];//anIntArray1482
							colorIndex += src;
							pixels[offset++] = rgb;
							pixels[offset++] = rgb;
							pixels[offset++] = rgb;
							pixels[offset++] = rgb;
						} while (--color > 0);
					}
					color = endX - startX & 0x3;
					if (color > 0) {
						rgb = invertedPalette[colorIndex >> 8];
						do {
							pixels[offset++] = rgb;
						} while (--color > 0);
					}
				} else {
					int j2 = alpha;
					int l2 = 256 - alpha;
					if (color > 0) {
						do {
							rgb = invertedPalette[colorIndex >> 8];
							colorIndex += src;
							rgb = (((rgb & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((rgb & 0xff00) * l2 >> 8 & 0xff00));
							int h = pixels[offset];
							pixels[offset++] = (rgb + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
							* j2 >> 8 & 0xff00));
							h = pixels[offset];
							pixels[offset++] = (rgb + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
							* j2 >> 8 & 0xff00));
							h = pixels[offset];
							pixels[offset++] = (rgb + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
							* j2 >> 8 & 0xff00));
							h = pixels[offset];
							pixels[offset++] = (rgb + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
							* j2 >> 8 & 0xff00));
						} while (--color > 0);
					}
					color = endX - startX & 0x3;
					if (color > 0) {
						rgb = invertedPalette[colorIndex >> 8];
						rgb = (((rgb & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((rgb & 0xff00) * l2 >> 8 & 0xff00));
						do {
							int i_61_ = pixels[offset];
							pixels[offset++] = (rgb + ((i_61_ & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((i_61_ & 0xff00)
							* j2 >> 8 & 0xff00));
						} while (--color > 0);
					}
				}
			} else {
				int step = (gradient - colorIndex) / (endX - startX);
				color = endX - startX;
				if (alpha == 0) {
					do {
						pixels[offset++] = invertedPalette[colorIndex >> 8];
						colorIndex += step;
					} while (--color > 0);
				} else {
					int alpha = Renderer3D.alpha;
					int srcAlpha = 256 - Renderer3D.alpha;
					do {
						rgb = invertedPalette[colorIndex >> 8];
						colorIndex += step;
						rgb = (((rgb & 0xff00ff) * srcAlpha >> 8 & 0xff00ff) + ((rgb & 0xff00)
						* srcAlpha >> 8 & 0xff00));
						int i = pixels[offset];
						pixels[offset++] = (rgb + ((i & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((i & 0xff00)
						* alpha >> 8 & 0xff00));
					} while (--color > 0);
				}
			}
		}
	}

	public static void drawTriangle(int y1, int y2, int y3, int x1, int x2, int x3, int color) {
		int slope1 = 0;
		if (y2 != y1) {
			slope1 = (x2 - x1 << 16) / (y2 - y1);
		}
		int slope2 = 0;
		if (y3 != y2) {
			slope2 = (x3 - x2 << 16) / (y3 - y2);
		}
		int slope3 = 0;
		if (y3 != y1) {
			slope3 = (x1 - x3 << 16) / (y1 - y3);
		}
		if ((y1 <= y2) && (y1 <= y3)) {
			if (y1 >= Renderer2D.bottomY) {
				return;
			}
			if (y2 > Renderer2D.bottomY) {
				y2 = Renderer2D.bottomY;
			}
			if (y3 > Renderer2D.bottomY) {
				y3 = Renderer2D.bottomY;
			}
			if (y2 < y3) {
				x3 = x1 <<= 16;
				if (y1 < 0) {
					x3 -= slope3 * y1;
					x1 -= slope1 * y1;
					y1 = 0;
				}
				x2 <<= 16;
				if (y2 < 0) {
					x2 -= slope2 * y2;
					y2 = 0;
				}
				if (((y1 != y2) && (slope3 < slope1)) || ((y1 == y2) && (slope3 > slope2))) {
					y3 -= y2;
					y2 -= y1;
					for (y1 = Renderer3D.lineOffsets[y1]; --y2 >= 0; y1 += Renderer2D.width) {
						Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x3 >> 16, x1 >> 16);
						x3 += slope3;
						x1 += slope1;
					}
					while (--y3 >= 0) {
						Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x3 >> 16, x2 >> 16);
						x3 += slope3;
						x2 += slope2;
						y1 += Renderer2D.width;
					}
					return;
				}
				y3 -= y2;
				y2 -= y1;
				for (y1 = Renderer3D.lineOffsets[y1]; --y2 >= 0; y1 += Renderer2D.width) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x1 >> 16, x3 >> 16);
					x3 += slope3;
					x1 += slope1;
				}
				while (--y3 >= 0) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x2 >> 16, x3 >> 16);
					x3 += slope3;
					x2 += slope2;
					y1 += Renderer2D.width;
				}
				return;
			}
			x2 = x1 <<= 16;
			if (y1 < 0) {
				x2 -= slope3 * y1;
				x1 -= slope1 * y1;
				y1 = 0;
			}
			x3 <<= 16;
			if (y3 < 0) {
				x3 -= slope2 * y3;
				y3 = 0;
			}
			if (((y1 != y3) && (slope3 < slope1)) || ((y1 == y3) && (slope2 > slope1))) {
				y2 -= y3;
				y3 -= y1;
				for (y1 = Renderer3D.lineOffsets[y1]; --y3 >= 0; y1 += Renderer2D.width) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x2 >> 16, x1 >> 16);
					x2 += slope3;
					x1 += slope1;
				}
				while (--y2 >= 0) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x3 >> 16, x1 >> 16);
					x3 += slope2;
					x1 += slope1;
					y1 += Renderer2D.width;
				}
				return;
			}
			y2 -= y3;
			y3 -= y1;
			for (y1 = Renderer3D.lineOffsets[y1]; --y3 >= 0; y1 += Renderer2D.width) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x1 >> 16, x2 >> 16);
				x2 += slope3;
				x1 += slope1;
			}
			while (--y2 >= 0) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y1, color, x1 >> 16, x3 >> 16);
				x3 += slope2;
				x1 += slope1;
				y1 += Renderer2D.width;
			}
			return;
		}
		if (y2 <= y3) {
			if (y2 >= Renderer2D.bottomY) {
				return;
			}
			if (y3 > Renderer2D.bottomY) {
				y3 = Renderer2D.bottomY;
			}
			if (y1 > Renderer2D.bottomY) {
				y1 = Renderer2D.bottomY;
			}
			if (y3 < y1) {
				x1 = x2 <<= 16;
				if (y2 < 0) {
					x1 -= slope1 * y2;
					x2 -= slope2 * y2;
					y2 = 0;
				}
				x3 <<= 16;
				if (y3 < 0) {
					x3 -= slope3 * y3;
					y3 = 0;
				}
				if (((y2 != y3) && (slope1 < slope2)) || ((y2 == y3) && (slope1 > slope3))) {
					y1 -= y3;
					y3 -= y2;
					for (y2 = Renderer3D.lineOffsets[y2]; --y3 >= 0; y2 += Renderer2D.width) {
						Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x1 >> 16, x2 >> 16);
						x1 += slope1;
						x2 += slope2;
					}
					while (--y1 >= 0) {
						Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x1 >> 16, x3 >> 16);
						x1 += slope1;
						x3 += slope3;
						y2 += Renderer2D.width;
					}
					return;
				}
				y1 -= y3;
				y3 -= y2;
				for (y2 = Renderer3D.lineOffsets[y2]; --y3 >= 0; y2 += Renderer2D.width) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x2 >> 16, x1 >> 16);
					x1 += slope1;
					x2 += slope2;
				}
				while (--y1 >= 0) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x3 >> 16, x1 >> 16);
					x1 += slope1;
					x3 += slope3;
					y2 += Renderer2D.width;
				}
				return;
			}
			x3 = x2 <<= 16;
			if (y2 < 0) {
				x3 -= slope1 * y2;
				x2 -= slope2 * y2;
				y2 = 0;
			}
			x1 <<= 16;
			if (y1 < 0) {
				x1 -= slope3 * y1;
				y1 = 0;
			}
			if (slope1 < slope2) {
				y3 -= y1;
				y1 -= y2;
				for (y2 = Renderer3D.lineOffsets[y2]; --y1 >= 0; y2 += Renderer2D.width) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x3 >> 16, x2 >> 16);
					x3 += slope1;
					x2 += slope2;
				}
				while (--y3 >= 0) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x1 >> 16, x2 >> 16);
					x1 += slope3;
					x2 += slope2;
					y2 += Renderer2D.width;
				}
				return;
			}
			y3 -= y1;
			y1 -= y2;
			for (y2 = Renderer3D.lineOffsets[y2]; --y1 >= 0; y2 += Renderer2D.width) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x2 >> 16, x3 >> 16);
				x3 += slope1;
				x2 += slope2;
			}
			while (--y3 >= 0) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y2, color, x2 >> 16, x1 >> 16);
				x1 += slope3;
				x2 += slope2;
				y2 += Renderer2D.width;
			}
			return;
		}
		if (y3 >= Renderer2D.bottomY) {
			return;
		}
		if (y1 > Renderer2D.bottomY) {
			y1 = Renderer2D.bottomY;
		}
		if (y2 > Renderer2D.bottomY) {
			y2 = Renderer2D.bottomY;
		}
		if (y1 < y2) {
			x2 = x3 <<= 16;
			if (y3 < 0) {
				x2 -= slope2 * y3;
				x3 -= slope3 * y3;
				y3 = 0;
			}
			x1 <<= 16;
			if (y1 < 0) {
				x1 -= slope1 * y1;
				y1 = 0;
			}
			if (slope2 < slope3) {
				y2 -= y1;
				y1 -= y3;
				for (y3 = Renderer3D.lineOffsets[y3]; --y1 >= 0; y3 += Renderer2D.width) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x2 >> 16, x3 >> 16);
					x2 += slope2;
					x3 += slope3;
				}
				while (--y2 >= 0) {
					Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x2 >> 16, x1 >> 16);
					x2 += slope2;
					x1 += slope1;
					y3 += Renderer2D.width;
				}
				return;
			}
			y2 -= y1;
			y1 -= y3;
			for (y3 = Renderer3D.lineOffsets[y3]; --y1 >= 0; y3 += Renderer2D.width) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x3 >> 16, x2 >> 16);
				x2 += slope2;
				x3 += slope3;
			}
			while (--y2 >= 0) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x1 >> 16, x2 >> 16);
				x2 += slope2;
				x1 += slope1;
				y3 += Renderer2D.width;
			}
			return;
		}
		x1 = x3 <<= 16;
		if (y3 < 0) {
			x1 -= slope2 * y3;
			x3 -= slope3 * y3;
			y3 = 0;
		}
		x2 <<= 16;
		if (y2 < 0) {
			x2 -= slope1 * y2;
			y2 = 0;
		}
		if (slope2 < slope3) {
			y1 -= y2;
			y2 -= y3;
			for (y3 = Renderer3D.lineOffsets[y3]; --y2 >= 0; y3 += Renderer2D.width) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x1 >> 16, x3 >> 16);
				x1 += slope2;
				x3 += slope3;
			}
			while (--y1 >= 0) {
				Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x2 >> 16, x3 >> 16);
				x2 += slope1;
				x3 += slope3;
				y3 += Renderer2D.width;
			}
			return;
		}
		y1 -= y2;
		y2 -= y3;
		for (y3 = Renderer3D.lineOffsets[y3]; --y2 >= 0; y3 += Renderer2D.width) {
			Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x3 >> 16, x1 >> 16);
			x1 += slope2;
			x3 += slope3;
		}
		while (--y1 >= 0) {
			Renderer3D.drawScanLine(Renderer2D.pixels, y3, color, x3 >> 16, x2 >> 16);
			x2 += slope1;
			x3 += slope3;
			y3 += Renderer2D.width;
		}
	}

	private static void drawScanLine(int pixels[], int offset, int loops, int startX, int endX) {
		int color;
		if (Renderer3D.edgeRestricted) {
			if (endX > Renderer2D.endX) {
				endX = Renderer2D.endX;
			}
			if (startX < 0) {
				startX = 0;
			}
		}
		if (startX >= endX) {
			return;
		}
		offset += startX;
		color = endX - startX >> 2;
		if (Renderer3D.alpha == 0) {
			while (--color >= 0) {
				pixels[offset] = loops;
				offset++;
				pixels[offset] = loops;
				offset++;
				pixels[offset] = loops;
				offset++;
				pixels[offset] = loops;
				offset++;
			}
			for (color = endX - startX & 3; --color >= 0;) {
				pixels[offset] = loops;
				offset++;
			}
			return;
		}
		int alpha = Renderer3D.alpha;
		int srcAlpha = 256 - Renderer3D.alpha;
		loops = ((loops & 0xff00ff) * srcAlpha >> 8 & 0xff00ff)
		+ ((loops & 0xff00) * srcAlpha >> 8 & 0xff00);
		while (--color >= 0) {
			pixels[offset] = loops + ((pixels[offset] & 0xff00ff) * alpha >> 8 & 0xff00ff)
			+ ((pixels[offset] & 0xff00) * alpha >> 8 & 0xff00);
			offset++;
			pixels[offset] = loops + ((pixels[offset] & 0xff00ff) * alpha >> 8 & 0xff00ff)
			+ ((pixels[offset] & 0xff00) * alpha >> 8 & 0xff00);
			offset++;
			pixels[offset] = loops + ((pixels[offset] & 0xff00ff) * alpha >> 8 & 0xff00ff)
			+ ((pixels[offset] & 0xff00) * alpha >> 8 & 0xff00);
			offset++;
			pixels[offset] = loops + ((pixels[offset] & 0xff00ff) * alpha >> 8 & 0xff00ff)
			+ ((pixels[offset] & 0xff00) * alpha >> 8 & 0xff00);
			offset++;
		}
		for (color = endX - startX & 3; --color >= 0;) {
			pixels[offset] = loops + ((pixels[offset] & 0xff00ff) * alpha >> 8 & 0xff00ff)
			+ ((pixels[offset] & 0xff00) * alpha >> 8 & 0xff00);
			offset++;
		}
	}

	public static void drawTexturedTriangle(int y1, int y2, int y3, int x1, int x2, int x3,
	int gradian1, int gradian2, int gradian3, int textureX1, int textureX2, int textureX3,
	int textureY1, int textureY2, int textureY3, int textureZ1, int textureZ2, int textureZ3,
	int textureId) {
		int pixels[] = Renderer3D.getTexture(textureId);
		Renderer3D.opaque = !Renderer3D.alphaTextures[textureId];
		textureX2 = textureX1 - textureX2;
		textureY2 = textureY1 - textureY2;
		textureZ2 = textureZ1 - textureZ2;
		textureX3 -= textureX1;
		textureY3 -= textureY1;
		textureZ3 -= textureZ1;
		int i1 = textureX3 * textureY1 - textureY3 * textureX1 << 14;
		int i2 = textureY3 * textureZ1 - textureZ3 * textureY1 << 8;
		int i3 = textureZ3 * textureX1 - textureX3 * textureZ1 << 5;
		int i4 = textureX2 * textureY1 - textureY2 * textureX1 << 14;
		int i5 = textureY2 * textureZ1 - textureZ2 * textureY1 << 8;
		int i6 = textureZ2 * textureX1 - textureX2 * textureZ1 << 5;
		int i7 = textureY2 * textureX3 - textureX2 * textureY3 << 14;
		int i8 = textureZ2 * textureY3 - textureY2 * textureZ3 << 8;
		int i9 = textureX2 * textureZ3 - textureZ2 * textureX3 << 5;
		int slope1 = 0;
		int slope2 = 0;
		if (y2 != y1) {
			slope1 = (x2 - x1 << 16) / (y2 - y1);
			slope2 = (gradian2 - gradian1 << 16) / (y2 - y1);
		}
		int slope3 = 0;
		int slope4 = 0;
		if (y3 != y2) {
			slope3 = (x3 - x2 << 16) / (y3 - y2);
			slope4 = (gradian3 - gradian2 << 16) / (y3 - y2);
		}
		int slope5 = 0;
		int slope6 = 0;
		if (y3 != y1) {
			slope5 = (x1 - x3 << 16) / (y1 - y3);
			slope6 = (gradian1 - gradian3 << 16) / (y1 - y3);
		}
		if ((y1 <= y2) && (y1 <= y3)) {
			if (y1 >= Renderer2D.bottomY) {
				return;
			}
			if (y2 > Renderer2D.bottomY) {
				y2 = Renderer2D.bottomY;
			}
			if (y3 > Renderer2D.bottomY) {
				y3 = Renderer2D.bottomY;
			}
			if (y2 < y3) {
				x3 = x1 <<= 16;
				gradian3 = gradian1 <<= 16;
				if (y1 < 0) {
					x3 -= slope5 * y1;
					x1 -= slope1 * y1;
					gradian3 -= slope6 * y1;
					gradian1 -= slope2 * y1;
					y1 = 0;
				}
				x2 <<= 16;
				gradian2 <<= 16;
				if (y2 < 0) {
					x2 -= slope3 * y2;
					gradian2 -= slope4 * y2;
					y2 = 0;
				}
				int i10 = y1 - Renderer2D.centerY;
				i1 += i3 * i10;
				i4 += i6 * i10;
				i7 += i9 * i10;
				if (((y1 != y2) && (slope5 < slope1)) || ((y1 == y2) && (slope5 > slope3))) {
					y3 -= y2;
					y2 -= y1;
					y1 = Renderer3D.lineOffsets[y1];
					while (--y2 >= 0) {
						Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x3 >> 16,
						x1 >> 16, gradian3 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
						x3 += slope5;
						x1 += slope1;
						gradian3 += slope6;
						gradian1 += slope2;
						y1 += Renderer2D.width;
						i1 += i3;
						i4 += i6;
						i7 += i9;
					}
					while (--y3 >= 0) {
						Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x3 >> 16,
						x2 >> 16, gradian3 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
						x3 += slope5;
						x2 += slope3;
						gradian3 += slope6;
						gradian2 += slope4;
						y1 += Renderer2D.width;
						i1 += i3;
						i4 += i6;
						i7 += i9;
					}
					return;
				}
				y3 -= y2;
				y2 -= y1;
				y1 = Renderer3D.lineOffsets[y1];
				while (--y2 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x1 >> 16, x3 >> 16,
					gradian1 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
					x3 += slope5;
					x1 += slope1;
					gradian3 += slope6;
					gradian1 += slope2;
					y1 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				while (--y3 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x2 >> 16, x3 >> 16,
					gradian2 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
					x3 += slope5;
					x2 += slope3;
					gradian3 += slope6;
					gradian2 += slope4;
					y1 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				return;
			}
			x2 = x1 <<= 16;
			gradian2 = gradian1 <<= 16;
			if (y1 < 0) {
				x2 -= slope5 * y1;
				x1 -= slope1 * y1;
				gradian2 -= slope6 * y1;
				gradian1 -= slope2 * y1;
				y1 = 0;
			}
			x3 <<= 16;
			gradian3 <<= 16;
			if (y3 < 0) {
				x3 -= slope3 * y3;
				gradian3 -= slope4 * y3;
				y3 = 0;
			}
			int i11 = y1 - Renderer3D.middleY;
			i1 += i3 * i11;
			i4 += i6 * i11;
			i7 += i9 * i11;
			if (((y1 != y3) && (slope5 < slope1)) || ((y1 == y3) && (slope3 > slope1))) {
				y2 -= y3;
				y3 -= y1;
				y1 = Renderer3D.lineOffsets[y1];
				while (--y3 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x2 >> 16, x1 >> 16,
					gradian2 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
					x2 += slope5;
					x1 += slope1;
					gradian2 += slope6;
					gradian1 += slope2;
					y1 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				while (--y2 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x3 >> 16, x1 >> 16,
					gradian3 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
					x3 += slope3;
					x1 += slope1;
					gradian3 += slope4;
					gradian1 += slope2;
					y1 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				return;
			}
			y2 -= y3;
			y3 -= y1;
			y1 = Renderer3D.lineOffsets[y1];
			while (--y3 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x1 >> 16, x2 >> 16,
				gradian1 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
				x2 += slope5;
				x1 += slope1;
				gradian2 += slope6;
				gradian1 += slope2;
				y1 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			while (--y2 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y1, x1 >> 16, x3 >> 16,
				gradian1 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
				x3 += slope3;
				x1 += slope1;
				gradian3 += slope4;
				gradian1 += slope2;
				y1 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			return;
		}
		if (y2 <= y3) {
			if (y2 >= Renderer2D.bottomY) {
				return;
			}
			if (y3 > Renderer2D.bottomY) {
				y3 = Renderer2D.bottomY;
			}
			if (y1 > Renderer2D.bottomY) {
				y1 = Renderer2D.bottomY;
			}
			if (y3 < y1) {
				x1 = x2 <<= 16;
				gradian1 = gradian2 <<= 16;
				if (y2 < 0) {
					x1 -= slope1 * y2;
					x2 -= slope3 * y2;
					gradian1 -= slope2 * y2;
					gradian2 -= slope4 * y2;
					y2 = 0;
				}
				x3 <<= 16;
				gradian3 <<= 16;
				if (y3 < 0) {
					x3 -= slope5 * y3;
					gradian3 -= slope6 * y3;
					y3 = 0;
				}
				int i12 = y2 - Renderer2D.centerY;
				i1 += i3 * i12;
				i4 += i6 * i12;
				i7 += i9 * i12;
				if (((y2 != y3) && (slope1 < slope3)) || ((y2 == y3) && (slope1 > slope5))) {
					y1 -= y3;
					y3 -= y2;
					y2 = Renderer3D.lineOffsets[y2];
					while (--y3 >= 0) {
						Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x1 >> 16,
						x2 >> 16, gradian1 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
						x1 += slope1;
						x2 += slope3;
						gradian1 += slope2;
						gradian2 += slope4;
						y2 += Renderer2D.width;
						i1 += i3;
						i4 += i6;
						i7 += i9;
					}
					while (--y1 >= 0) {
						Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x1 >> 16,
						x3 >> 16, gradian1 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
						x1 += slope1;
						x3 += slope5;
						gradian1 += slope2;
						gradian3 += slope6;
						y2 += Renderer2D.width;
						i1 += i3;
						i4 += i6;
						i7 += i9;
					}
					return;
				}
				y1 -= y3;
				y3 -= y2;
				y2 = Renderer3D.lineOffsets[y2];
				while (--y3 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x2 >> 16, x1 >> 16,
					gradian2 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
					x1 += slope1;
					x2 += slope3;
					gradian1 += slope2;
					gradian2 += slope4;
					y2 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				while (--y1 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x3 >> 16, x1 >> 16,
					gradian3 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
					x1 += slope1;
					x3 += slope5;
					gradian1 += slope2;
					gradian3 += slope6;
					y2 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				return;
			}
			x3 = x2 <<= 16;
			gradian3 = gradian2 <<= 16;
			if (y2 < 0) {
				x3 -= slope1 * y2;
				x2 -= slope3 * y2;
				gradian3 -= slope2 * y2;
				gradian2 -= slope4 * y2;
				y2 = 0;
			}
			x1 <<= 16;
			gradian1 <<= 16;
			if (y1 < 0) {
				x1 -= slope5 * y1;
				gradian1 -= slope6 * y1;
				y1 = 0;
			}
			int i13 = y2 - Renderer3D.middleY;
			i1 += i3 * i13;
			i4 += i6 * i13;
			i7 += i9 * i13;
			if (slope1 < slope3) {
				y3 -= y1;
				y1 -= y2;
				y2 = Renderer3D.lineOffsets[y2];
				while (--y1 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x3 >> 16, x2 >> 16,
					gradian3 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
					x3 += slope1;
					x2 += slope3;
					gradian3 += slope2;
					gradian2 += slope4;
					y2 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				while (--y3 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x1 >> 16, x2 >> 16,
					gradian1 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
					x1 += slope5;
					x2 += slope3;
					gradian1 += slope6;
					gradian2 += slope4;
					y2 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				return;
			}
			y3 -= y1;
			y1 -= y2;
			y2 = Renderer3D.lineOffsets[y2];
			while (--y1 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x2 >> 16, x3 >> 16,
				gradian2 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
				x3 += slope1;
				x2 += slope3;
				gradian3 += slope2;
				gradian2 += slope4;
				y2 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			while (--y3 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y2, x2 >> 16, x1 >> 16,
				gradian2 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
				x1 += slope5;
				x2 += slope3;
				gradian1 += slope6;
				gradian2 += slope4;
				y2 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			return;
		}
		if (y3 >= Renderer2D.bottomY) {
			return;
		}
		if (y1 > Renderer2D.bottomY) {
			y1 = Renderer2D.bottomY;
		}
		if (y2 > Renderer2D.bottomY) {
			y2 = Renderer2D.bottomY;
		}
		if (y1 < y2) {
			x2 = x3 <<= 16;
			gradian2 = gradian3 <<= 16;
			if (y3 < 0) {
				x2 -= slope3 * y3;
				x3 -= slope5 * y3;
				gradian2 -= slope4 * y3;
				gradian3 -= slope6 * y3;
				y3 = 0;
			}
			x1 <<= 16;
			gradian1 <<= 16;
			if (y1 < 0) {
				x1 -= slope1 * y1;
				gradian1 -= slope2 * y1;
				y1 = 0;
			}
			int i14 = y3 - Renderer3D.middleY;
			i1 += i3 * i14;
			i4 += i6 * i14;
			i7 += i9 * i14;
			if (slope3 < slope5) {
				y2 -= y1;
				y1 -= y3;
				y3 = Renderer3D.lineOffsets[y3];
				while (--y1 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x2 >> 16, x3 >> 16,
					gradian2 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
					x2 += slope3;
					x3 += slope5;
					gradian2 += slope4;
					gradian3 += slope6;
					y3 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				while (--y2 >= 0) {
					Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x2 >> 16, x1 >> 16,
					gradian2 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
					x2 += slope3;
					x1 += slope1;
					gradian2 += slope4;
					gradian1 += slope2;
					y3 += Renderer2D.width;
					i1 += i3;
					i4 += i6;
					i7 += i9;
				}
				return;
			}
			y2 -= y1;
			y1 -= y3;
			y3 = Renderer3D.lineOffsets[y3];
			while (--y1 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x3 >> 16, x2 >> 16,
				gradian3 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
				x2 += slope3;
				x3 += slope5;
				gradian2 += slope4;
				gradian3 += slope6;
				y3 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			while (--y2 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x1 >> 16, x2 >> 16,
				gradian1 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
				x2 += slope3;
				x1 += slope1;
				gradian2 += slope4;
				gradian1 += slope2;
				y3 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			return;
		}
		x1 = x3 <<= 16;
		gradian1 = gradian3 <<= 16;
		if (y3 < 0) {
			x1 -= slope3 * y3;
			x3 -= slope5 * y3;
			gradian1 -= slope4 * y3;
			gradian3 -= slope6 * y3;
			y3 = 0;
		}
		x2 <<= 16;
		gradian2 <<= 16;
		if (y2 < 0) {
			x2 -= slope1 * y2;
			gradian2 -= slope2 * y2;
			y2 = 0;
		}
		int i15 = y3 - Renderer3D.middleY;
		i1 += i3 * i15;
		i4 += i6 * i15;
		i7 += i9 * i15;
		if (slope3 < slope5) {
			y1 -= y2;
			y2 -= y3;
			y3 = Renderer3D.lineOffsets[y3];
			while (--y2 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x1 >> 16, x3 >> 16,
				gradian1 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
				x1 += slope3;
				x3 += slope5;
				gradian1 += slope4;
				gradian3 += slope6;
				y3 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			while (--y1 >= 0) {
				Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x2 >> 16, x3 >> 16,
				gradian2 >> 8, gradian3 >> 8, i1, i4, i7, i2, i5, i8);
				x2 += slope1;
				x3 += slope5;
				gradian2 += slope2;
				gradian3 += slope6;
				y3 += Renderer2D.width;
				i1 += i3;
				i4 += i6;
				i7 += i9;
			}
			return;
		}
		y1 -= y2;
		y2 -= y3;
		y3 = Renderer3D.lineOffsets[y3];
		while (--y2 >= 0) {
			Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x3 >> 16, x1 >> 16,
			gradian3 >> 8, gradian1 >> 8, i1, i4, i7, i2, i5, i8);
			x1 += slope3;
			x3 += slope5;
			gradian1 += slope4;
			gradian3 += slope6;
			y3 += Renderer2D.width;
			i1 += i3;
			i4 += i6;
			i7 += i9;
		}
		while (--y1 >= 0) {
			Renderer3D.drawTexturedLine(Renderer2D.pixels, pixels, y3, x3 >> 16, x2 >> 16,
			gradian3 >> 8, gradian2 >> 8, i1, i4, i7, i2, i5, i8);
			x2 += slope1;
			x3 += slope5;
			gradian2 += slope2;
			gradian3 += slope6;
			y3 += Renderer2D.width;
			i1 += i3;
			i4 += i6;
			i7 += i9;
		}
	}

	private static void drawTexturedLine(int pixels[], int texture[], int offset, int startX,
	int endX, int colorIndex, int gradient, int arg9, int arg10, int arg11, int arg12, int arg13,
	int arg14) {
		int arg2 = 0;
		int arg3 = 0;
		if (startX >= endX) {
			return;
		}
		int step;
		int loops;
		if (Renderer3D.edgeRestricted) {
			step = (gradient - colorIndex) / (endX - startX);
			if (endX > Renderer2D.endX) {
				endX = Renderer2D.endX;
			}
			if (startX < 0) {
				colorIndex -= startX * step;
				startX = 0;
			}
			if (startX >= endX) {
				return;
			}
			loops = endX - startX >> 3;
			step <<= 12;
			colorIndex <<= 9;
		} else {
			if (endX - startX > 7) {
				loops = endX - startX >> 3;
				step = (gradient - colorIndex) * Renderer3D.gradientFactors[loops] >> 6;
			} else {
				loops = 0;
				step = 0;
			}
			colorIndex <<= 9;
		}
		offset += startX;
		if (Renderer3D.lowMem) {
			int i4 = 0;
			int k4 = 0;
			int k6 = startX - Renderer3D.middleX;
			arg9 += (arg12 >> 3) * k6;
			arg10 += (arg13 >> 3) * k6;
			arg11 += (arg14 >> 3) * k6;
			int i5 = arg11 >> 12;
			if (i5 != 0) {
				arg2 = arg9 / i5;
				arg3 = arg10 / i5;
				if (arg2 < 0) {
					arg2 = 0;
				} else if (arg2 > 4032) {
					arg2 = 4032;
				}
			}
			arg9 += arg12;
			arg10 += arg13;
			arg11 += arg14;
			i5 = arg11 >> 12;
			if (i5 != 0) {
				i4 = arg9 / i5;
				k4 = arg10 / i5;
				if (i4 < 7) {
					i4 = 7;
				} else if (i4 > 4032) {
					i4 = 4032;
				}
			}
			int i7 = i4 - arg2 >> 3;
			int k7 = k4 - arg3 >> 3;
			arg2 += (colorIndex & 0x600000) >> 3;
			int i8 = colorIndex >> 23;
			if (Renderer3D.opaque) {
				while (loops-- > 0) {
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 = i4;
					arg3 = k4;
					offset++;
					arg9 += arg12;
					arg10 += arg13;
					arg11 += arg14;
					int j5 = arg11 >> 12;
					if (j5 != 0) {
						i4 = arg9 / j5;
						k4 = arg10 / j5;
						if (i4 < 7) {
							i4 = 7;
						} else if (i4 > 4032) {
							i4 = 4032;
						}
					}
					i7 = i4 - arg2 >> 3;
					k7 = k4 - arg3 >> 3;
					colorIndex += step;
					arg2 += (colorIndex & 0x600000) >> 3;
					i8 = colorIndex >> 23;
				}
				for (loops = endX - startX & 7; loops-- > 0;) {
					pixels[offset] = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8;
					arg2 += i7;
					arg3 += k7;
					offset++;
				}
				return;
			}
			while (loops-- > 0) {
				int k8;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
				if ((k8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = k8;
				}
				offset++;
				arg2 = i4;
				arg3 = k4;
				arg9 += arg12;
				arg10 += arg13;
				arg11 += arg14;
				int k5 = arg11 >> 12;
				if (k5 != 0) {
					i4 = arg9 / k5;
					k4 = arg10 / k5;
					if (i4 < 7) {
						i4 = 7;
					} else if (i4 > 4032) {
						i4 = 4032;
					}
				}
				i7 = i4 - arg2 >> 3;
				k7 = k4 - arg3 >> 3;
				colorIndex += step;
				arg2 += (colorIndex & 0x600000) >> 3;
				i8 = colorIndex >> 23;
			}
			for (loops = endX - startX & 7; loops-- > 0;) {
				int l8;
				if ((l8 = texture[(arg3 & 4032) + (arg2 >> 6)] >>> i8) != 0) {
					pixels[offset] = l8;
				}
				offset++;
				arg2 += i7;
				arg3 += k7;
			}
			return;
		}
		int j4 = 0;
		int l4 = 0;
		int l6 = startX - Renderer3D.middleX;
		arg9 += (arg12 >> 3) * l6;
		arg10 += (arg13 >> 3) * l6;
		arg11 += (arg14 >> 3) * l6;
		int l5 = arg11 >> 14;
		if (l5 != 0) {
			arg2 = arg9 / l5;
			arg3 = arg10 / l5;
			if (arg2 < 0) {
				arg2 = 0;
			} else if (arg2 > 16256) {
				arg2 = 16256;
			}
		}
		arg9 += arg12;
		arg10 += arg13;
		arg11 += arg14;
		l5 = arg11 >> 14;
		if (l5 != 0) {
			j4 = arg9 / l5;
			l4 = arg10 / l5;
			if (j4 < 7) {
				j4 = 7;
			} else if (j4 > 16256) {
				j4 = 16256;
			}
		}
		int j7 = j4 - arg2 >> 3;
		int l7 = l4 - arg3 >> 3;
		arg2 += colorIndex & 0x600000;
		int j8 = colorIndex >> 23;
		if (Renderer3D.opaque) {
			while (loops-- > 0) {
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 = j4;
				arg3 = l4;
				offset++;
				arg9 += arg12;
				arg10 += arg13;
				arg11 += arg14;
				int i6 = arg11 >> 14;
				if (i6 != 0) {
					j4 = arg9 / i6;
					l4 = arg10 / i6;
					if (j4 < 7) {
						j4 = 7;
					} else if (j4 > 16256) {
						j4 = 16256;
					}
				}
				j7 = j4 - arg2 >> 3;
				l7 = l4 - arg3 >> 3;
				colorIndex += step;
				arg2 += colorIndex & 0x600000;
				j8 = colorIndex >> 23;
			}
			for (loops = endX - startX & 7; loops-- > 0;) {
				pixels[offset] = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8;
				arg2 += j7;
				arg3 += l7;
				offset++;
			}
			return;
		}
		while (loops-- > 0) {
			int i9;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
			if ((i9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = i9;
			}
			offset++;
			arg2 = j4;
			arg3 = l4;
			arg9 += arg12;
			arg10 += arg13;
			arg11 += arg14;
			int j6 = arg11 >> 14;
			if (j6 != 0) {
				j4 = arg9 / j6;
				l4 = arg10 / j6;
				if (j4 < 7) {
					j4 = 7;
				} else if (j4 > 16256) {
					j4 = 16256;
				}
			}
			j7 = j4 - arg2 >> 3;
			l7 = l4 - arg3 >> 3;
			colorIndex += step;
			arg2 += colorIndex & 0x600000;
			j8 = colorIndex >> 23;
		}
		for (int l3 = endX - startX & 7; l3-- > 0;) {
			int j9;
			if ((j9 = texture[(arg3 & 0x3f80) + (arg2 >> 7)] >>> j8) != 0) {
				pixels[offset] = j9;
			}
			offset++;
			arg2 += j7;
			arg3 += l7;
		}
	}

	public static boolean lowMem = true;
	public static boolean edgeRestricted;
	private static boolean opaque;
	public static boolean colorRestricted = true;
	public static int alpha;
	public static int middleX;
	public static int middleY;
	private static int[] gradientFactors;
	public static final int[] invertedColors;
	public static int sineTable[];
	public static int cosineTable[];
	public static int lineOffsets[];
	private static int textureCount;
	public static IndexedSprite textures[] = new IndexedSprite[50];
	private static boolean[] alphaTextures = new boolean[50];
	private static int[] averageTextureColors = new int[50];
	private static int loadedTextures;
	private static int[][] texturePool;
	private static int[][] textureCache = new int[50][];
	public static int texturePriorities[] = new int[50];
	public static int priority;
	public static int invertedPalette[] = new int[0x10000];
	private static int[][] texturePixels = new int[50][];
	static {
		Renderer3D.gradientFactors = new int[512];
		invertedColors = new int[2048];
		Renderer3D.sineTable = new int[2048];
		Renderer3D.cosineTable = new int[2048];
		for (int i = 1; i < 512; i++) {
			Renderer3D.gradientFactors[i] = 32768 / i;
		}
		for (int j = 1; j < 2048; j++) {
			Renderer3D.invertedColors[j] = 0x10000 / j;
		}
		for (int k = 0; k < 2048; k++) {
			Renderer3D.sineTable[k] = (int) (65536D * Math.sin(k * 0.0030679614999999999D));
			Renderer3D.cosineTable[k] = (int) (65536D * Math.cos(k * 0.0030679614999999999D));
		}
	}
}
